#define _CRT_SECURE_NO_WARNINGS 1
#include"Stack.h"
void InitStack(linknode*  &s)
{
	s = (linknode*)malloc(sizeof(linknode));
	s->next = NULL;
}
void DestroyStack(linknode* &s)
{
	linknode* tmp = s->next;
	while (tmp)
	{
		free(s);
		s = tmp;
		tmp = tmp->next;
	}
	free(s);
}
bool StackEmpty(linknode* s)
{
	return(s->next == NULL);
}
void Push(linknode* &s, ElemType e)
{
	linknode* tmp;
	tmp=(linknode*)malloc(sizeof(linknode));
	tmp->data = e;
	tmp->next = s->next;
	s->next = tmp;
}
bool Pop(linknode* &s, ElemType &e)
{
	linknode* tmp=s->next;
	if (s->next == NULL)
	{
		return false;
	}
	e=tmp->data;
	s->next = tmp->next;
	free(tmp);
	return true;
}
bool GetTop(linknode* s, ElemType &e)
{
	if (s->next == NULL)
	{
		return false;
	}
	e = s->next->data;
	return true;
}
void conversion(ElemType N)
{
	linknode* S;
	ElemType e;
	InitStack(S);
	while (N)
	{
		Push(S, N % 8);
		N /= 8;
	}
	while (!StackEmpty(S))
	{
		Pop(S, e);
		printf("%d ", e);
	}

}
